/**
 * @FileName Client.java
 * @Package com.designMode.memento
 * -------------------------------------
 * @function Please write description of function
 * @Date 2016-1-19 上午10:52:01
 * -------------------------------------
 * Copyright (c) 2016,顾博君 All Rights Reserved.
 */
package com.designMode.memento;

/**
 * @author 顾博君
 * @ClassName Client
 * @Date 2016-1-19 上午10:52:01
 * @Function 场景类
 */
public class Client {
    public static void main(String[] args) {
        // 定义发起人
        Originator originator = new Originator();
        // 定义备忘录管理者
        Caretaker caretaker = new Caretaker();
        // 创建一个备忘录
        caretaker.setMemento(originator.createMemento());
        // 读取备忘录内容
        System.out.println("备忘录状态：" + caretaker.getMemento().getState());
        System.out.println("发起人状态：" + originator.getState());
        // 改变发起人内容
        originator.setState("new state");
        // 读取发起人内容
        System.out.println("发起人状态：" + originator.getState());
        // 恢复一个备忘录
        originator.restoreMemento(caretaker.getMemento());
        System.out.println("发起人状态：" + originator.getState());
    }
}
